package com.summer.safe.quartz.config;


import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 *
 * QuartzConfig配置
 * 
 * @author
 */
@Configuration
public class QuartzConfig {
	@Autowired
	private SpringJobFactory springJobFactory;
	@Bean
	public SchedulerFactoryBean schedulerFactoryBean() throws Exception {
		SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
		schedulerFactoryBean.setJobFactory(springJobFactory);
		schedulerFactoryBean.afterPropertiesSet();
		return schedulerFactoryBean;
	}
	@Bean(name="scheduler")
	public Scheduler scheduler() throws Exception{
		Scheduler scheduler=schedulerFactoryBean().getScheduler();
		scheduler.start();
		return scheduler;
	}
}